package com.example.newcalculator;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
        //throw new UnsupportedOperationException("Not yet implemented");
        if ("ans.setText()".equals(intent.getAction())) {

            Bundle bundle = intent.getExtras();
            if (bundle != null) {

                String text = bundle.getString("text");
                Toast.makeText(context, "成功接收广播" + text, Toast.LENGTH_LONG).show();
            }
        }
    }
}